package com.zy.mc_module.ui.setting.setpay;

import com.zy.mc_module.mvp.bean.BaseBean;
import com.zy.mc_module.utils.MD5;
import com.zy.mc_module.utils.UserUtils;
import com.zy.mc_module.utils.retrofit.RetrofitManager;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;

/**
 * author : dq
 * date   : 19/4/16
 * desc   :
 */
public class SetPayModel implements SetPayContract.Model {

    @Override
    public Observable<BaseBean> setPayPwd(Object... objects) {
        Map<String, Object> map = new HashMap<>();
        map.put("appUserId", UserUtils.getUid());
        map.put("payPwd", MD5.md5((String) objects[0]));
        return RetrofitManager.getInstance().getApi().setPayPwd(map);
    }

    @Override
    public Observable<BaseBean> checkPayPwd(Object... objects) {
        Map<String, Object> map = new HashMap<>();
        map.put("appUserId", UserUtils.getUid());
        map.put("payPwd", MD5.md5((String) objects[0]));
        return RetrofitManager.getInstance().getApi().checkPayPwd(map);
    }

    @Override
    public Observable<BaseBean> changePayPwd(Object... objects) {
        Map<String, Object> map = new HashMap<>();
        map.put("appUserId", UserUtils.getUid());
        map.put("oldPayPwd", MD5.md5((String) objects[0]));
        map.put("newPayPwd", MD5.md5((String) objects[1]));
        return RetrofitManager.getInstance().getApi().changePayPwd(map);
    }

    @Override
    public Observable<BaseBean> forgetPayPwd(Object... objects) {
        Map<String, Object> map = new HashMap<>();
        map.put("appUserId", UserUtils.getUid());
        map.put("code", objects[0]);
        map.put("newPayPwd", MD5.md5((String) objects[1]));
        return RetrofitManager.getInstance().getApi().forgetPayPwd(map);
    }
}
